<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">授权</block>			
		</cu-custom>
		<view class="padding-xs flex align-center">
			<view class="flex-sub text-center">
				<view class="text-sm padding">
					<open-data class="cu-avatar xl round margin-left" type="userAvatarUrl"></open-data>
				</view>
				<view class="padding"><open-data class="text-center" type="userNickName"></open-data></view>
			</view>
		</view>
		<view class="uni-btn-v uni-common-mt uni-form-button padding-xl">
			<button type="primary" open-type="getUserInfo" @getuserinfo="openSetting">授权获取用户信息</button>
			<!-- <button open-type="openSetting" @opensetting="open">打开设置页</button> -->
		</view>
		
	</view>
</template>

<script>
	import formatData from '@/common/formData.js';
	export default {
		data() {
			return {
				
			}
		},
		created() {
			console.log('load setting');
			// this.isSetting();
		},
		methods: {
			open: function(res){
				console.log(res);
			},
			openSetting: function(res){
				var _this = this;
				console.log(res);
				_this.isSetting();
			},
			isSetting: function(){
				var _this = this;
				uni.getSetting({
				    success(res) {
						console.log(res.authSetting);
						if(res.authSetting['scope.userInfo']){
							//获取本地的用户信息
							formatData.getUserinfo(function(user){
								if(!user.userId){
									uni.reLaunch({
										url: '/pages/login/bind'
									});
								}
							});
						}
				    }
				})
			}
		}
	}
</script>

<style>

</style>
